#============================================================
#	Drawer
#============================================================
# 抽屉
#============================================================
# @datetime: 2022-3-23 11:37:35
#============================================================
extends Control


const DURATION_TIME = 0.35


onready var host : Control = get_parent()
onready var tween : Tween = $Tween


func _ready():
	yield(get_tree(), "idle_frame")
	host.rect_global_position.x = -host.rect_size.x


func _on_Button_toggled(button_pressed):
	get_tree().paused = button_pressed
	if button_pressed:
		tween.interpolate_property(
			host, "rect_global_position:x",
			host.rect_global_position.x, 0,
			DURATION_TIME, Tween.TRANS_CUBIC, Tween.EASE_OUT
		)
	else:
		tween.interpolate_property(
			host, "rect_global_position:x",
			host.rect_global_position.x, -host.rect_size.x,
			DURATION_TIME, Tween.TRANS_CUBIC, Tween.EASE_OUT
		)
	tween.start()
